﻿@using System.Data
@model LeadMaster.ViewModels.ViewModelSurveys

<div class="spacer"></div>
   <div style="left: 20px; margin-left: 20px; margin-right:20px;">
@using (Html.BeginForm("Survey","Outsourcer"))
{
    @Html.ValidationSummary(true)
    <fieldset>
    <legend>@Model.LeadTemplate.Title : @(Model.QuestionNumber) of @(Model.TotalQuestionCount)</legend>
 
    @Html.HiddenFor(model => model.Surveys.SurveyID)
    @Html.HiddenFor(model => model.LeadStat.LeadStatID)
    @Html.HiddenFor(model => model.LeadStatQuestions.LeadStatQuestionsID)
    @Html.HiddenFor(model => model.StartFlag)
    @Html.HiddenFor(model => model.BlockID)
    @Html.HiddenFor(model => model.LeadResults.LeadStatQuestionsID)
    @Html.HiddenFor(model => model.TotalQuestionCount)
    @Html.HiddenFor(model => model.UserID)
    @Html.HiddenFor(model => model.Agent)
    @Html.HiddenFor(model => model.CallCentreID)
    
    <div class="spacer"></div>
    @if (Model.QuestionNumber == 1)
    {
        <div><label style="font-family: 'Trebuchet MS'; font-size: 20px; font-variant: small-caps; color: #0000FF">@Model.Person.Title @Model.Person.Forename @Model.Person.Surname, @Model.Person.Address1, @Model.Person.TownCity, @Model.Person.Postcode</label></div>
    }

    <input id="LeadStatQuestionID" name="LeadStatQuestionID" type="hidden" value="@Model.LeadStatQuestionID" />    <input id="QuestionNumber" name="QuestionNumber" type="hidden" value="@Model.QuestionNumber" />    <input type="hidden" name="StartFlag" value="false" />
    <label>"@Model.LeadResults.Question"</label>
    <div class="spacer"></div>
    
    @if (@Model.LeadStatQuestions.Notes != null)
    {
    <div style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #91622e; font-style: italic;">@Model.LeadStatQuestions.Notes</div>
    }     
    <div class="spacer"></div>
    @switch (Model.LeadStatQuestions.AnswerType)
    {
        case "C":
            if (Model.LeadStatQuestions.DropDown == true && Model.LeadStatQuestions.AcceptedAnswerChar != null)
            {
                        <select id="LeadResults_Answer" name="LeadResults.Answer" style="width:300px;" class="chosen">
                        <option></option>
                        @foreach (var answeritems in Model.LeadStatQuestions.AcceptedAnswerChar.Split(','))
                        {
                            <option value="@(answeritems)">@answeritems</option>
                        }
                        </select>
            }
            else
            {
                        <input class="largetextbox valid" id="LeadResults_Answer" name="LeadResults.Answer" type="text" aria-invalid="false" tabindex="1">
            }
            break;
        case "L":
                    <input type="checkbox" name="LeadResults.Answer" id="LeadResults_Answer" value="Yes"/>
            break;
        case "I":
            break;
        default:
            break;
    }

    <div class="spacer"></div>
    <input type="submit" value="Next Question" disabled="disabled" id="submitbutton" tabindex="2"/>
    <div class="spacer"></div>
    @Html.LabelFor(m => m.JumpToEnd) @Html.EditorFor(m => m.JumpToEnd)
</fieldset>
}
</div>
<div class="spacer"></div>

@if (Model.dtMappings != null)
{
    <div>
    <table style="border-style: solid; border-color: #999999; font-family: 'Trebuchet MS'; font-size: 11px; width: 600px;  margin-left: 20px;">
    <tr style="border-style: solid; border-color: #999999">
    <th>Survey</th><th>Question</th><th>Required Answer</th><th>Your Answer</th><th>Status</th>
    </tr>
    @foreach (DataRow row in Model.dtMappings.Rows)
    {
        <tr>
        @foreach (DataColumn column in Model.dtMappings.Columns)
        {
            if (column.Ordinal<5)
            {
            <td  @if (row.ItemArray[5].ToString().Length!=0)
	        {
                @: style="color: #999999"
	        }
            else
            {
                @: style="color: #000000"
            }
            >
            @row[column]
            </td>
            }
        }
        </tr>
    }
    </table>
    </div>
}


<script type="text/javascript">
    $(document).ready(function () {

        $(".chosen").chosen();

        $("#LeadResults_Answer").focus();

        $("#LeadResults_Answer").blur(function () {
            $("#submitbutton").focus();
        });

        $("#LeadResults_Answer").change(function () {
            $("#submitbutton").prop('disabled', false);
        });

        $("#JumpToEnd").click(function () {
            $("#submitbutton").val("Go To End Of Survey");
            $("#submitbutton").prop('disabled', false);
        });
    });
</script>